package at.fhj.swd.pse.helper;

import java.util.List;

import javax.annotation.PostConstruct;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.jboss.logging.Logger;

import at.fhj.swd.pse.data.CommunityDAO;
import at.fhj.swd.pse.entities.Community;

@Stateless
public class CommunityManager {				
	private static final Logger logger = Logger.getLogger(CommunityManager.class);

	@PersistenceContext
	private EntityManager em;
	
	public CommunityManager() {
		
	}

	@PostConstruct
	public void init() {
		logger.info("init");
	}

	public List<Community> getCommunities() {
		CommunityDAO c_dao = DAOFactory.INSTANCE.CreateCommunityDAO(em);
		
		return c_dao.getCommunities();
	}
	
	public Community getCommunity(int id) {
		return DAOFactory.INSTANCE.CreateCommunityDAO(em).getCommunity(id);		
	}
}
